<%@page import="myJDBC.lowLevel.Attributes"%>
<%@page import="myJDBC.lowLevel.ObjectTypes"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="ISO-8859-1"%>
        <%@ page import="java.util.*"%>
<%@page import="myJDBC.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style>
<%@include file="smallJsps/styles.jsp" %>
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<%@include file="smallJsps/bootstrapInclude.jsp" %>
</head>
<body>
<%@include file="smallJsps/logoutButton.jsp" %>
<%@include file="smallJsps/checkAdmin.jsp" %>
<div class="row-fluid">
		<div class="span6 offset2">
	<form action="SrvlCreateObjectType" name="formCrObjType2" method="POST">
		<%
			int parId=-1;
			if (request.getParameter("name") == "") {
				response.sendRedirect("createObjectType");
			}
			String name = request.getParameter("name");
			parId = Integer.parseInt(request.getParameter("selParent"));
			out.print("<b>name= </b><label name=\"name\">"+ name+"</label><br>");
		 %>
		 <table class="table-striped table-condensed">
			 <tr><th>Unbind parent attributes</th></tr>
			 <tr><td>
			 	<%
			 		ArrayList<String> parenAttrib= new ArrayList<String>();
			 		if(parId!=-1){
						ArrayList<String> tmp = ObjectTypes.returnObjectType(parId);						
						int barier= tmp.indexOf(null); 
						for (int i =barier+1; i < tmp.size(); i = i + 3) {
							parenAttrib.add(tmp.get(i));
						}
						for (int i =barier+1; i < tmp.size(); i = i + 3) {
							out.print("<input type=\"checkbox\" checked=\"checked\""); 
							out.println("name=\"parAttribute\" value=" + tmp.get(i)
								+ "> " + tmp.get(i + 1)
								+ "<Br>");
						}
					}
			 	%>			 
			 </td></tr>
		 </table>
		<table class="table-striped table-condensed">
			<tr><th>Check attributes</th></tr>
			<tr><td>
			<%	
				ArrayList<String> listWithAttributes = Attributes.returnAttributes();
				for (int i = 0; i < listWithAttributes.size(); i = i + 3) {					
					//if(parId!=-1)
						if(!parenAttrib.contains(listWithAttributes.get(i))){
							out.print("<input type=\"checkbox\"");  
							out.print("name=\"attribute\" value=" + listWithAttributes.get(i)
									+ "> " + listWithAttributes.get(i + 1));
							out.println("<select name=\"bind"+listWithAttributes.get(i)+"\"><option value=\"0\" selected=\"selected\">public</option><option value=\"1\" >private</option></select><br>");
						}	
				}				
				out.print("<input type=\"hidden\" name=\"parIdInt\" value="+parId+">");
				out.print("<input type=\"hidden\" name=\"name\" value="+name+">");
			%>
			</td></tr>
		</table>	
		<input class="btn btn-large btn-primary" type="submit" value="Create">	
	</form>
	<form method="get" action="privateOffice"><button class="btn" type="submit">privateOffice</button></form>
	</div>
	</div>
</body>
</html>